#!/bin/sh

# Check if the record really does not exist.
cleandig host-255.test.dyndns ANY hidesoadetails

# check if a domain exists, this should result in an NXDomain (section 3.2.1)
# if the check fails, it will delete a record, which should not happen.
cleannsupdate <<!
server $nameserver $port
zone test.dyndns
prereq yxdomain host-255.test.dyndns
update delete host-1.test.dyndns
send
answer
!

# check if the record is still there.
cleandig host-1.test.dyndns ANY

# check if the record exists, should result in an NXRRSET (section 3.2.1)
# if the check fails, it will delete a record.
cleannsupdate <<!
server $nameserver $port
zone test.dyndns
prereq yxrrset host-255.test.dyndns A
update delete host-1.test.dyndns
send
answer
!

# check if the records still exists, and query the record record to be deleted.
cleandig host-1.test.dyndns A
cleandig host-2.test.dyndns A

# check if host-2 does not exist, if so, delete host-2.
# this checks section 3.2.2
cleannsupdate <<!
server $nameserver $port
zone test.dyndns
prereq nxdomain host-2.test.dyndns
update delete host-2.test.dyndns
send
answer
!

# if the check worked, this record is still there.
cleandig host-2.test.dyndns A

# check if the specific record type still exists, if not the case, delete it.
cleannsupdate <<!
server $nameserver $port
zone test.dyndns
prereq nxrrset host-2.test.dyndns A
update delete host-2.test.dyndns
send
answer
!

# if the check worked, this record still exists.
cleandig host-2.test.dyndns A

# Check ENT records
cleannsupdate <<!
server $nameserver $port
zone test.dyndns
prereq yxdomain host.test.dyndns
send
answer
!
